import { defHttp } from '/@/utils/http/axios';

// 获取所选目录下零件数据(带所有对应下层数据)
export const getPartData = (superid: string) =>
  defHttp.get({ url: `/services/app/Prdfolder/GetPrdPartData?superid=${superid}` });

// 获取对应可创建零件类型列表和零件下附件文件类型列表
export const getPartType = (FolderId: string) =>
  defHttp.post({ url: `/services/app/Task/GetAddPartFileTypeList?FolderId=${FolderId}` });

// 获取添加零件的属性值列表
export const getPartAttr = (PartType: string) =>
  defHttp.post({ url: `/services/app/Task/GetAddPartProp?PartType=${PartType}` });

// 新建零件
export const AddPartAndFile = (params: any) =>
  defHttp.post({
    url: `/services/app/Task/AddPartAndFile`,
    data: params,
  });

// 单个零件的附件文件上传
export const UploadPartFile = (formData: any) =>
  defHttp.post({
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    url: `/services/app/Task/UpLoadPartFile`,
    params: formData,
  });

// 删除单个零件的附件文件
export const DeletePartFile = (FileName: string) =>
  defHttp.delete({
    url: `/services/app/Task/DeletePartFile?FileName=${FileName}`,
  });

// 零件不走流程直接检入
export const PartJustCheckIn = (PartId: string) =>
  defHttp.post({
    url: `/services/app/PartRevision/PartJustCheckIn?PartId=${PartId}`,
  });

// 零件不走流程直接检出
export const PartJustCheckOut = (PartId: string, UpdateVersion: string) =>
  defHttp.post({
    url: `/services/app/PartRevision/PartJustCheckOut?PartId=${PartId}&UpdateVersion=${UpdateVersion}`,
  });

// 撤销零件
export const RevokePart = (PartId: string) =>
  defHttp.post({
    url: `/services/app/PartRevision/RevokePart?PartId=${PartId}`,
  });

// 删除全版本零件
export const DeleteAllVersionFile = (PartId: string) =>
  defHttp.delete({
    url: `/services/app/PartRevision/DeleteAllVersionFile?PartId=${PartId}`,
  });

// 零件走流程前判断
export const PartCanAddWorkflowIns = (PartId: string, version: string, WorkflowType: string) =>
  defHttp.post({
    url: `/services/app/WorkflowInstances/PartCanAddWorkflowIns?PartId=${PartId}&version=${version}&WorkflowType=${WorkflowType}`,
  });

// 获取对应零件的详情属性
export const GetPartDetail = (PartId: string, PartVersion: string) =>
  defHttp.post({
    url: `/services/app/PartRevision/GetPartDetail?PartId=${PartId}&PartVersion=${PartVersion}`,
  });

// 修改零件
export const UpdatePart = (params: any) =>
  defHttp.post({
    url: `/services/app/Task/ChangePartAndFile`,
    data: params,
  });

// 获取对应零件的产品结构树状图相关信息
export const GetPartStructure = (PartId: string | string[], PartVersion: string | string[]) =>
  defHttp.get({
    url: `/services/app/PartRevision/GetPartStructure?PartId=${PartId}&PartVersion=${PartVersion}`,
  });

// 获取对应零件的产品结构表格内容
export const GetPartStructureTable = (PartId: string | string[], PartVersion: string | string[]) =>
  defHttp.get({
    url: `/services/app/PartRevision/GetPartStructureTable?PartId=${PartId}&PartVersion=${PartVersion}`,
  });

// 获取零件的产品结构中树状图所选内容对应表格内容
export const GetPartStructureTableByTree = (
  Id: string | number,
  Version: string | number,
  Type: string,
  SelectTime: string,
) =>
  defHttp.get({
    url: `/services/app/PartRevision/GetPartStructureAndFileTable?Id=${Id}&Version=${Version}&Type=${Type}&SelectTime=${SelectTime}`,
  });
